<?php 
require 'kernel/common.php';

$Immophp_adm = new immophp_adm($db, $lang, $Session);

$Query = "
SELECT 
    COUNT(id) AS totalannonce,
    (SELECT COUNT(id) FROM immo_annonce WHERE active = 1) as annonce_active,
    (SELECT COUNT(id) FROM immo_annonce WHERE active = 1 AND cdc = 1) as annonce_cdc,
    (SELECT COUNT(id) FROM immo_annonce WHERE vendu = 1 OR vendu = 2) as annonce_vendu
    FROM immo_annonce
";
$StatAnnonce = $db->sql_query($Query,'ARRAY');

$AnnonceMaxVue = $db->sql_query("SELECT titre, date_ajout, nb_vue FROM immo_annonce ORDER BY nb_vue DESC LIMIT 1",'ARRAY');
$StatAnnonce['normal'] = $StatAnnonce['annonce_active'] - $StatAnnonce['annonce_cdc'];
$AnnonceMaxVue['date_ajout'] = date('d/m/Y', $AnnonceMaxVue['date_ajout']);

$smarty->assign('event_user', immophp_adm::get_alert() );
$smarty->assign('_session', $_SESSION);
$smarty->assign('lang', $lang);
$smarty->assign('StatAnnonce', $StatAnnonce);
$smarty->assign('AnnonceMaxVue', $AnnonceMaxVue);
$smarty->assign('user_online', $Immophp_adm->get_user_online() );

$smarty->display('index.tpl');

require_once 'footer.php';
?>